home *** CD-ROM | disk | FTP | other *** search
/ Cocktail Hour / image.iso / COCKTAIL.DIR / Internal_54_MaxPrint v3.0.ls < prev    next >
Encoding:
Text File  |  1997-03-05  |  9.7 KB  |  331 lines

  1. on maxprint printType
  2.   global gPropFont, printer
  3.   cursor(4)
  4.   set gPropFont to "times new roman"
  5.   openXLib("pmatic.dll")
  6.   set printer to PrintOMatic(mnew)
  7.   printer(mRegister, "pmat130-067-01107")
  8.   printer(mReset)
  9.   if printType = "map" then
  10.     printmap()
  11.   else
  12.     if printType = "tour" then
  13.       printTour()
  14.     else
  15.       if printType = "text" then
  16.         printText()
  17.       end if
  18.     end if
  19.   end if
  20.   printer(mdispose)
  21.   closeXLib("pmatic.dll")
  22.   cursor(-1)
  23. end
  24.  
  25. on printmap
  26.   global w, h, print
  27.   if item 5 of field "MaxField" = "metro" then
  28.     printer(mSetLandScapemode, 1)
  29.   else
  30.     printer(mSetLandScapemode, 0)
  31.   end if
  32.   set mapToPrint to the value of item 1 of field "MaxField"
  33.   set w to printer(mGetPageWidth)
  34.   set h to printer(mGetPageheight)
  35.   set mapName to item 4 of field "maxfield"
  36.   printer(mSetMargins, 1, 1, 1, 1)
  37.   printer(mSetTextStyle, "bold,underline")
  38.   set halve to printer(mGetPaperWidth) / 2
  39.   printer(mSetTextSize, 24)
  40.   printer(mSetTextJust, "centered")
  41.   printer(mdrawText, mapName, halve, 40)
  42.   printer(mNewPage)
  43.   if item 5 of field "MaxField" = "metro" then
  44.     AppendBitMap(mapToPrint, 1, 55, "metro")
  45.   else
  46.     AppendBitMap(mapToPrint, 1, 55, "map")
  47.   end if
  48.   if item 2 of field "MaxField" > -1 then
  49.     set arrowx to the value of item 2 of field "MaxField"
  50.     set arrowy to the value of item 3 of field "MaxField"
  51.     AppendBitMap("arrow", arrowx, arrowy, "arrow")
  52.   end if
  53.   printingProc()
  54. end
  55.  
  56. on AppendBitMap TheBitMap, left, top, whatToPrint
  57.   global w, h, print, forArrowTop, forArrowLeft, prop
  58.   set y to the height of cast TheBitMap
  59.   set x to the width of cast TheBitMap
  60.   if whatToPrint = "tour" then
  61.     if x > (w - 5) then
  62.       set x to w - 5
  63.       set y to (y * w / x) + 30
  64.     end if
  65.   else
  66.     if whatToPrint = "map" then
  67.       set oldY to y
  68.       set oldX to x
  69.       set y to printer(mGetPageheight) - top - 60
  70.       set x to (oldX * y / oldY) + 0.0
  71.       set prop to y / (oldY + 0.0)
  72.       set left to (printer(mGetPageWidth) / 2.0) - (x / 2.0)
  73.       set x to left + x
  74.       set y to top + y
  75.       set forArrowTop to top
  76.       set forArrowLeft to left
  77.       set left to integer(left)
  78.       set x to integer(x)
  79.     else
  80.       if whatToPrint = "metro" then
  81.         set oldY to y
  82.         set oldX to x
  83.         set x to printer(mGetPageWidth)
  84.         set y to (oldY * x / oldX) + 0.0
  85.         set prop to x / (oldX + 0.0)
  86.         set top to (printer(mGetPageheight) / 2.0) - (y / 2.0)
  87.         set x to left + x
  88.         set y to top + y
  89.         set forArrowTop to top
  90.         set forArrowLeft to left
  91.         set top to integer(top)
  92.         set y to integer(y)
  93.       else
  94.         if whatToPrint = "arrow" then
  95.           set left to left * prop
  96.           set top to top * prop
  97.           if item 5 of field "MaxField" = "metro" then
  98.           end if
  99.           set left to integer(left - (x / 2) + forArrowLeft)
  100.           set top to integer(top - y + forArrowTop)
  101.           set top to top - 7
  102.           set x to integer(left + x)
  103.           set y to integer(top + y)
  104.         end if
  105.       end if
  106.     end if
  107.   end if
  108.   printer(mPicture, the picture of member TheBitMap, left, top, x, y)
  109.   if whatToPrint = "tour" then
  110.   end if
  111. end
  112.  
  113. on printText
  114.   global w, h, gPropFont, printer
  115.   printer(mSetMargins, 72, 72, 72, 72)
  116.   set w to printer(mGetPageWidth)
  117.   set h to printer(mGetPageheight)
  118.   MySetUp()
  119.   printer(mNewPage)
  120.   printer(mTextBox, 22, 42, w, h, 0)
  121.   repeat with cnt = 1 to the number of lines in field "MaxField"
  122.     set CastToPrint to integer(the value of item 1 of line cnt of field "Maxfield")
  123.     AppendStyledText(printer, CastToPrint, 1)
  124.   end repeat
  125.   printingProc()
  126. end
  127.  
  128. on printTour
  129.   global printer
  130.   set w to printer(mGetPageWidth)
  131.   set h to printer(mGetPageheight)
  132.   MySetUp()
  133.   printer(mNewPage)
  134.   set mapName to line 1 of field "maxfield"
  135.   printer(mSetMargins, 1, 1, 1, 1)
  136.   printer(mSetTextStyle, "bold,underline")
  137.   set halve to printer(mGetPaperWidth) / 2
  138.   printer(mSetTextSize, 24)
  139.   printer(mSetTextJust, "left")
  140.   printer(mdrawText, mapName, 35, 55)
  141.   set whatToPrint to "tour"
  142.   set TheBitMap to the value of line 2 of field "MaxField"
  143.   AppendBitMap(TheBitMap, 235, 70, "tour")
  144.   printer(mSetTextJust, "left")
  145.   printer(mSetTextStyle, "plain")
  146.   printer(mTextBox, 35, 60, w, h, 1)
  147.   printer(mSetTextSize, 16)
  148.   repeat with i = 3 to the number of lines in field "MaxField"
  149.     set tourtext to line i of field "MaxField"
  150.     AppendStyledText(printer, the value of tourtext, 1)
  151.   end repeat
  152.   printingProc()
  153. end
  154.  
  155. on MySetUp
  156.   global printer, w, h, gPropFont
  157.   printer(mSetLandScapemode, 0)
  158.   printer(mSetMargins, 72, 72, 72, 72)
  159.   set w to printer(mGetPageWidth)
  160.   set h to printer(mGetPageheight)
  161.   printer(mSetTextFont, gPropFont)
  162.   printer(mSetTextSize, 12)
  163.   printer(mSetTextStyle, "italic")
  164.   printer(mSetPageNumSymbol, "├₧")
  165.   printer(mSetTextJust, "left")
  166.   printer(mdrawText, "Cocktails", 22, 35)
  167.   printer(mSetTextJust, "right")
  168.   printer(mdrawText, "page ├₧", w, 35)
  169.   printer(mLine, 22, 38, w, 38)
  170.   printer(mSetTextJust, "left")
  171.   printer(mSetTextStyle, "plain")
  172. end
  173.  
  174. on AppendStyledText obj, theCast, autoAppend
  175.   if not objectp(obj) then
  176.     exit
  177.   end if
  178.   if not integerp(theCast) and not stringp(theCast) then
  179.     exit
  180.   end if
  181.   if not integerp(autoAppend) then
  182.     set autoAppend to 0
  183.   end if
  184.   set styleList to BuildStyleList1(theCast)
  185.   repeat with cnt = 1 to count(styleList)
  186.     set styleRun to getAt(styleList, cnt)
  187.     obj(mSetTextFont, getaProp(styleRun, #font))
  188.     obj(mSetTextSize, getaProp(styleRun, #size))
  189.     obj(mSetTextStyle, getaProp(styleRun, #style))
  190.     set charsAdded to obj(mAppendText, char getaProp(styleRun, #start) to getaProp(styleRun, #end) of field theCast, autoAppend)
  191.     if charsAdded = 0 then
  192.       exit
  193.     end if
  194.   end repeat
  195. end
  196.  
  197. on BuildStyleList theCast
  198.   global printSource, tournumber
  199.   if printSource = "tours" then
  200.     set diff to 500
  201.   else
  202.     if printSource = "general" then
  203.       set diff to 7140
  204.     else
  205.       if printSource = "objects" then
  206.         set diff to 120
  207.       end if
  208.     end if
  209.   end if
  210.   if (the name of cast theCast = "maxspace") or (the name of cast theCast = "maxfield2") or (the name of cast theCast = "theEmpty") then
  211.     set styleList to BuildStyleList1(theCast)
  212.   else
  213.     if printSource = "tours" then
  214.       put theCast + 20
  215.       set styleList to the value of the text of cast (theCast + 20)
  216.     else
  217.       if (printSource = "objects") and (theCast > 366) then
  218.         set styleList to the value of line theCast - 366 of field "stylelists3"
  219.       else
  220.         if (printSource = "objects") and (theCast > 275) then
  221.           set styleList to the value of line theCast - 275 of field "stylelists2"
  222.         else
  223.           if (printSource = "general") and ((theCast - diff) > 35) then
  224.             set styleList to the value of line theCast - diff - 35 of field "Stylelists2"
  225.           else
  226.             set styleList to the value of line theCast - diff of field "stylelists"
  227.           end if
  228.         end if
  229.       end if
  230.     end if
  231.   end if
  232.   return styleList
  233. end
  234.  
  235. on BuildStyleList1 theCast
  236.   set styleList to []
  237.   set curFont to EMPTY
  238.   set curSize to 0
  239.   set curStyle to EMPTY
  240.   repeat with cnt = 1 to the number of chars in the text of member theCast
  241.     if (the textFont of char cnt of field theCast <> curFont) or (the textSize of char cnt of field theCast <> curSize) or (the textStyle of char cnt of field theCast <> curStyle) then
  242.       if count(styleList) then
  243.         setaProp(getAt(styleList, count(styleList)), #end, cnt - 1)
  244.       end if
  245.       set curFont to the textFont of char cnt of member theCast
  246.       set curSize to the textSize of char cnt of member theCast
  247.       set curStyle to the textStyle of char cnt of member theCast
  248.       add(styleList, [#font: curFont, #size: curSize, #style: curStyle, #start: cnt, #end: cnt])
  249.     end if
  250.   end repeat
  251.   if count(styleList) then
  252.     setaProp(getAt(styleList, count(styleList)), #end, the number of chars in the text of member theCast)
  253.   end if
  254.   return styleList
  255. end
  256.  
  257. on printingProc
  258.   if the controlDown then
  259.     printer(mPrintPreview)
  260.   else
  261.     printer(mPrint)
  262.   end if
  263. end
  264.  
  265. on fontSalvation firstcast, lastcast
  266.   set counter to 0
  267.   repeat with i = firstcast to lastcast
  268.     put i
  269.     set counter to counter + 1
  270.     if the castType of cast i = #text then
  271.       if char the number of chars in the name of cast i of the name of cast i = "G" then
  272.         set x to BuildStyleList1(i)
  273.       else
  274.         set x to " "
  275.       end if
  276.     end if
  277.     put x into line counter of field "stylelists"
  278.   end repeat
  279. end
  280.  
  281. on xxx
  282.   repeat with i = 1 to the number of lines in field "stylelists"
  283.     put i && char 1 to 6 of line i of field "stylelists" && the name of cast (i + 120)
  284.   end repeat
  285. end
  286.  
  287. on mapsmats
  288.   set counter to 1
  289.   set mapheight to 0
  290.   set mapwidth to 0
  291.   repeat with i = 1 to 5
  292.     repeat with j = 1 to 4
  293.       set mw to the width of cast "map" & counter
  294.       set mh to the height of cast "map" & counter
  295.       set mapwidth to mw + mapwidth
  296.       put integer(mapwidth) && integer(mapheight) into line counter of field "mapsmats"
  297.       set counter to counter + 1
  298.     end repeat
  299.     set mapheight to mapheight + 698
  300.     set mapwidth to 0
  301.   end repeat
  302. end
  303.  
  304. on fontSalvation2 firstcast, lastcast
  305.   set counter to 0
  306.   repeat with i = firstcast to lastcast
  307.     put i
  308.     set counter to counter + 1
  309.     if the castType of cast i = #text then
  310.       if char the number of chars in the name of cast i of the name of cast i = "G" then
  311.         set x to BuildStyleList1(i)
  312.       else
  313.         set x to " "
  314.       end if
  315.     end if
  316.     put x into line counter of field "stylelists"
  317.     set fff to the number of chars in field "stylelists"
  318.     put fff
  319.     if fff > 32000 then
  320.       exit repeat
  321.     end if
  322.   end repeat
  323. end
  324.  
  325. on tourproblem x, y
  326.   repeat with i = x to y
  327.     set fontlist to BuildStyleList1(i)
  328.     put fontlist into line 1 of field (i + 20)
  329.   end repeat
  330. end
  331.